<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>model::point</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Geometry">
<link rel="up" href="../models.html" title="Models">
<link rel="prev" href="../models.html" title="Models">
<link rel="next" href="model_d2_point_xy.html" title="model::d2::point_xy">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../models.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="model_d2_point_xy.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="geometry.reference.models.model_point"></a><a class="link" href="model_point.html" title="model::point">model::point</a>
</h4></div></div></div>
<p>
          <a class="indexterm" name="idm45246422243968"></a><a class="indexterm" name="idm45246422243280"></a>
Basic point class, having coordinates defined in a neutral way.
        </p>
<h6>
<a name="geometry.reference.models.model_point.h0"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.description"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.description">Description</a>
        </h6>
<p>
          Defines a neutral point class, fulfilling the Point Concept. Library users
          can use this point class, or use their own point classes. This point class
          is used in most of the samples and tests of Boost.Geometry This point class
          is used occasionally within the library, where a temporary point class
          is necessary.
        </p>
<h6>
<a name="geometry.reference.models.model_point.h1"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.model_of"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.model_of">Model
          of</a>
        </h6>
<p>
          <a class="link" href="../concepts/concept_point.html" title="Point Concept">Point Concept</a>
        </p>
<h6>
<a name="geometry.reference.models.model_point.h2"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.synopsis"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.synopsis">Synopsis</a>
        </h6>
<p>
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">CoordinateType</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">DimensionCount</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">CoordinateSystem</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span>
<span class="special">{</span>
  <span class="comment">// ...</span>
<span class="special">};</span>
</pre>
<p>
        </p>
<h6>
<a name="geometry.reference.models.model_point.h3"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.template_parameter_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.template_parameter_s_">Template
          parameter(s)</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Parameter
                  </p>
                </th>
<th>
                  <p>
                    Description
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    typename CoordinateType
                  </p>
                </td>
<td>
                  <p>
                    numerical type (int, double, ttmath, ...)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    std::size_t DimensionCount
                  </p>
                </td>
<td>
                  <p>
                    number of coordinates, usually 2 or 3
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    typename CoordinateSystem
                  </p>
                </td>
<td>
                  <p>
                    coordinate system, for example cs::cartesian
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.models.model_point.h4"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.constructor_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.constructor_s_">Constructor(s)</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Function
                  </p>
                </th>
<th>
                  <p>
                    Description
                  </p>
                </th>
<th>
                  <p>
                    Parameters
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">point</span><span class="special">()</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Default constructor, no initialization.
                  </p>
                </td>
<td>
                </td>
</tr>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">C</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if_t</span><span class="special">&lt;</span> <span class="identifier">geometry</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">is_coordinates_number_leq</span><span class="special">&lt;</span> <span class="identifier">C</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">DimensionCount</span> <span class="special">&gt;::</span><span class="identifier">value</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;&gt;</span>
<span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v0</span><span class="special">)</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Constructor to set one value.
                  </p>
                </td>
<td>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v0</em></span>:
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">C</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if_t</span><span class="special">&lt;</span> <span class="identifier">geometry</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">is_coordinates_number_leq</span><span class="special">&lt;</span> <span class="identifier">C</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">DimensionCount</span> <span class="special">&gt;::</span><span class="identifier">value</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;&gt;</span>
<span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v0</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v1</span><span class="special">)</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Constructor to set two values.
                  </p>
                </td>
<td>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v0</em></span>:
                  </p>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v1</em></span>:
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">C</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if_t</span><span class="special">&lt;</span> <span class="identifier">geometry</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">is_coordinates_number_leq</span><span class="special">&lt;</span> <span class="identifier">C</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">DimensionCount</span> <span class="special">&gt;::</span><span class="identifier">value</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;&gt;</span>
<span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v0</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v1</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">v2</span><span class="special">)</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Constructor to set three values.
                  </p>
                </td>
<td>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v0</em></span>:
                  </p>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v1</em></span>:
                  </p>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>v2</em></span>:
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.models.model_point.h5"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.member_function_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.member_function_s_">Member
          Function(s)</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Function
                  </p>
                </th>
<th>
                  <p>
                    Description
                  </p>
                </th>
<th>
                  <p>
                    Parameters
                  </p>
                </th>
<th>
                  <p>
                    Returns
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">K</span><span class="special">&gt;</span>
<span class="keyword">constexpr</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span>  <span class="special">&amp;</span> <span class="identifier">get</span><span class="special">()</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Get a coordinate.
                  </p>
                </td>
<td>
                </td>
<td>
                  <p>
                    the coordinate
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">K</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">value</span><span class="special">)</span></pre>
<p>
                  </p>
                </td>
<td>
                  <p>
                    Set a coordinate.
                  </p>
                </td>
<td>
                  <p>
                    <span class="bold"><strong>CoordinateType const &amp;</strong></span>:
                    <span class="emphasis"><em>value</em></span>: value to set
                  </p>
                </td>
<td>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.models.model_point.h6"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.header"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.header">Header</a>
        </h6>
<p>
          Either
        </p>
<p>
          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        </p>
<p>
          Or
        </p>
<p>
          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        </p>
<h6>
<a name="geometry.reference.models.model_point.h7"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.examples"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.examples">Examples</a>
        </h6>
<p>
          Declaration and use of the Boost.Geometry model::point, modelling the Point
          Concept
        </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">&gt;</span> <span class="identifier">point1</span><span class="special">;</span>
    <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">&gt;</span> <span class="identifier">point2</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">3.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c0" href="model_point.html#geometry.reference.models.model_point.c1"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>

    <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;(</span><span class="identifier">point1</span><span class="special">,</span> <span class="number">1.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c2" href="model_point.html#geometry.reference.models.model_point.c3"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a>
    <span class="identifier">point1</span><span class="special">.</span><span class="identifier">set</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;(</span><span class="number">2.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c4" href="model_point.html#geometry.reference.models.model_point.c5"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a>

    <span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">get</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;(</span><span class="identifier">point1</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c6" href="model_point.html#geometry.reference.models.model_point.c7"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a>
    <span class="keyword">double</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">point1</span><span class="special">.</span><span class="identifier">get</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;();</span> <a class="co" name="geometry.reference.models.model_point.c8" href="model_point.html#geometry.reference.models.model_point.c9"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a>

    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">x</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">y</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
        </p>
<div class="calloutlist"><table border="0" summary="Callout list">
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c1"></a><a href="#geometry.reference.models.model_point.c0"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              Construct, assigning three coordinates
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c3"></a><a href="#geometry.reference.models.model_point.c2"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              Set a coordinate, generic.
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c5"></a><a href="#geometry.reference.models.model_point.c4"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              Set a coordinate, class-specific (<span class="bold"><strong>Note</strong></span>:
              prefer <code class="computeroutput"><span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special">()</span></code>).
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c7"></a><a href="#geometry.reference.models.model_point.c6"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              Get a coordinate, generic.
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c9"></a><a href="#geometry.reference.models.model_point.c8"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              Get a coordinate, class-specific (<span class="bold"><strong>Note</strong></span>:
              prefer <code class="computeroutput"><span class="identifier">bg</span><span class="special">::</span><span class="identifier">get</span><span class="special">()</span></code>).
            </p></td>
</tr>
</table></div>
<p>
          Output:
        </p>
<pre class="programlisting">1, 2
</pre>
<h6>
<a name="geometry.reference.models.model_point.h8"></a>
          <span class="phrase"><a name="geometry.reference.models.model_point.notes"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.notes">Notes</a>
        </h6>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
            Coordinates are not initialized. If the constructor with parameters is
            not called and points are not assigned using <code class="computeroutput"><span class="identifier">set</span></code>
            or <code class="computeroutput"><span class="identifier">assign</span></code> then the coordinate
            values will contain garbage
          </p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2021 Barend Gehrels,
      Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../models.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="model_d2_point_xy.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
